<template>
  <div class="panel-container panel-group" :style="{height:height,width:width}">
    <el-row>
      <el-col :span="12" class="card-panel-col">
        <div class="card-panel" @click="handleSetPieChartData('all')">
          <div class="card-panel-description">
            <div class="card-panel-text">
              总设备数
            </div>
            <div class="card-panel-num">{{ counts.all }}</div>
          </div>
        </div>
      </el-col>
      <el-col :span="12" class="card-panel-col">
        <div class="card-panel" @click="handleSetPieChartData('online')">
          <div class="card-panel-description">
            <div class="card-panel-text">
              在线设备数
            </div>
            <div class="card-panel-num">{{ counts.online }}</div>
          </div>
        </div>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12" class="card-panel-col">
        <div class="card-panel" @click="handleSetPieChartData('status')">
          <div class="card-panel-description">
            <div class="card-panel-text">
              开启设备数
            </div>
            <div class="card-panel-num">{{ counts.status }}</div>
          </div>
        </div>
      </el-col>
      <el-col :span="12" class="card-panel-col">
        <div class="card-panel" @click="handleSetPieChartData('alarm')">
          <div class="card-panel-description">
            <div class="card-panel-text">
              报警设备数
            </div>
            <div class="card-panel-num">{{ counts.alarm }}</div>
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  props: {
    width: {
      type: String,
      default: '100%'
    },
    height: {
      type: String,
      default: '300px'
    },
    counts: {
      type: Object,
      required: true,
      default: null
    }
  },
  methods: {
    handleSetPieChartData(type) {
      this.$emit('handleSetPieChartData', type)
    }
  }
}
</script>

<style lang="scss" scoped>
.panel-group {
  .card-panel-col {
    margin-bottom: 32px;
  }

  .card-panel {
    text-align: center;
    height: 118px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
    border-color: rgba(0, 0, 0, .05);

    .card-panel-icon-wrapper {
      margin: 14px 0 0 14px;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }

    .card-panel-icon {
      font-size: 48px;
    }

    .card-panel-description {
      font-weight: bold;
      margin: 26px;
      margin-left: 0px;

      .card-panel-text {
        line-height: 18px;
        color: rgba(0, 0, 0, 0.45);
        font-size: 16px;
        margin-bottom: 12px;
      }

      .card-panel-num {
        font-size: 20px;
      }
    }
  }
}

@media (max-width: 550px) {
  .card-panel-description {
    display: none;
  }
}
</style>
